﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EuroManager.Domain.Simulator.AI;
using EuroManager.Domain.Simulator.AI.States;
using EuroManager.Domain.Simulator.Engine;
using EuroManager.Domain.Simulator.Helpers;
using EuroManager.Domain.Simulator.Tests.Tactics;
using EuroManager.Domain.Simulator.Tests.World;
using EuroManager.Domain.Simulator.World;
using NUnit.Framework;
using Rhino.Mocks;

namespace EuroManager.Domain.Simulator.Tests.AI
{
    [TestFixture]
    public class PlayerAITests
    {
        private PlayerAI ai;
        private IPlayer player;

        [SetUp]
        public void SetUp()
        {
            player = MockRepository.GenerateMock<IPlayer>();
            ai = new PlayerAI(player, new FakeRandomizer());
        }

        [Test]
        public void ShouldAssignToPlayer()
        {
            FakeGameWorld world = new FakeGameWorld();
            Player player = world.AddPlayer();

            PlayerAI ai = new PlayerAI(player, new FakeRandomizer());

            Assert.AreSame(ai, player.AI);
        }

        [Test]
        public void ShouldExecuteState()
        {
            IState state = MockRepository.GenerateMock<IState>();
            state.Expect(s => s.Execute());

            ai.ChangeState(state);
            TestHelper.Advance(1, ai);

            state.VerifyAllExpectations();
        }

        [Test]
        public void ShouldTurnToBallWhenNotMoving()
        {
            player.Stub(p => p.IsMoving).Return(false);
            player.Expect(p => p.TurnToBall());

            TestHelper.Advance(1, ai);

            player.VerifyAllExpectations();
        }
    }
}
